﻿using BasicMoudle.IRepostory;
using BasicMoudle.Repostory;

namespace BasicMoudle.Model
{
    public class IocModule
    {
        public IocModule() { }

        public void Run()
        {
            //依赖注入
            ServiceCollection services = new ServiceCollection();
            services.AddTransient<IProductRepository, ProductRepository>();
            services.AddTransient<IProductRepository, ProductTwoRepository>();
            ServiceProvider proVider = services.BuildServiceProvider();
            //var ser = proVider.GetRequiredService<IServiceProvider>();
            //scope
            //var scope = proVider.CreateScope();
            var one = proVider.GetRequiredService<IProductRepository>();
            var two = proVider.GetService<IProductRepository>();
            var three = proVider.GetServices<IProductRepository>();
        }
    }
}
